import historyApi from 'api/history'

// state
let state = {
  list: {
    params: {}, // 获取参数
    data: {} // 分页数据
  },
  history_race: {},
  history_have: false // 从赛事历史详情跳转过来的
}

// getters
const getters = {
  history_list: state => state.list,
  history_race: state => state.history_race,
  history_have: state => state.history_have
}

// actions
const actions = {
  history_list ({ commit, state }, params) {
    historyApi.list(params).then((json) => {
      commit('HISTORY_LIST', {
        params: params,
        data: json.data
      })
    })
  }
}
// mutations
const mutations = {
  HISTORY_LIST (state, { data, params }) {
    state.list = data
  },
  HISTORY_RACE (state, data) {
    state.history_race = data
  },
  HISTORY_HAVE (state, bol) {
    state.history_have = bol
  }
}

export default {
  state,
  getters,
  actions,
  mutations
}
